icon-theme: Fix deadlock in GktIconTheme dispose
authorAlexander Larsson <alexl@redhat.com>
Wed, 22 Apr 2020 12:20:33 +0000 (14:20 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 22 Apr 2020 16:20:57 +0000 (12:20 -0400)
commite75bc2833dbf40d8c50ff6ade4c8f868e62f5305
tree715018f06feab263ad6df0716c6db29656373572
parente026a04e039866bcaba34c5e9b28303abf44f801
icon-theme: Fix deadlock in GktIconTheme dispose

When freeing the display GtkIconTheme and that was the last owner we
ran into a deadlock, because we unref the "next-to-last" ref inside a
gtk_icon_theme_ref_aquire/release() pair, which makes the final unref
to happen in the release(), while the ref lock still was held.
The unref triggers dispose which tries to NULL out the ref, but that then
deadlocks on the mutex being held by the caller already.

We fix this by moving the release unref outside the lock. This is safe
because refcounts are atomic, and we *do* own the ref.
gtk/gtkicontheme.c